import router from "@/router";

export function setupPermission() {
  router.beforeEach(async (to, from, next) => {
    if (to.path === "/login" || to.path === "/") {
      next();
    } else {
      const userInfo = ref<any>("");
      if (localStorage.getItem("TOKEN_KEY")) {
        userInfo.value = localStorage.getItem("userInfo");
        userInfo.value = JSON.parse(userInfo.value);
        if (userInfo.value.username == "13562490161") {
          next();
        } else {
          next("/");
        }
      } else {
        next("/");
      }
    }
  });
}
